# Maintainer: Sireesh Kodali <scarface@disroot.org>
pkgname=firmware-motorola-potter
pkgver=2
pkgrel=3
pkgdesc="Firmware for Motorola Moto G5 Plus"
url="https://github.com/scarface-one/firmware-motorola-potter"
arch="aarch64"
license="proprietary"
options="!check !strip !archcheck !tracedeps"
_commit="cce83e64585c036facd4cef39f47bc23d18ba2e9"
builddir="$srcdir/$pkgname-$_commit/lib/firmware/postmarketos"
subpackages="$pkgname-openrc"
_fwdir="/lib/firmware"

source="
	$pkgname-$_commit.tar.gz::$url/archive/$_commit.tar.gz
	moto-modem-rfs-setup.openrc
"

package() {
	# GPU Firmware files
	install -Dm644 a506_zap.b02 -t "$pkgdir/$_fwdir/qcom/msm8953/motorola/potter"
	install -Dm644 a506_zap.mdt -t "$pkgdir/$_fwdir/qcom/msm8953/motorola/potter"

	# WLAN Firmware
	install -Dm644 wlan/prima/WCNSS_qcom_wlan_nv.bin -t "$pkgdir/$_fwdir/postmarketos/wlan/prima"
}

openrc() {
	install_if="$pkgname=$pkgver-r$pkgrel openrc"
	install="$subpkgname.post-install $subpkgname.post-upgrade"

	install -Dm755 $srcdir/moto-modem-rfs-setup.openrc "$subpkgdir"/etc/init.d/moto-modem-rfs-setup
}

sha512sums="
5a35ff1b567b672585f761eddbc772163f52b312c1e94410eff4b1d333852857a2f87769a45f47f7bcff373bdd5b062c3d16110e0211d85f83a7b4c6c78f6d3c  firmware-motorola-potter-cce83e64585c036facd4cef39f47bc23d18ba2e9.tar.gz
d4fd0f3406c9f004e9cae7bc500c5713aab75f102f8e3ea1af820865f01eb03def01cd9ed3e8a184c7dfc22ab419628fad17957a3782885d96eb36e94461e842  moto-modem-rfs-setup.openrc
"
